# tools/example_tool.py
import os
import sys
from typing import Optional

# Add parent dir
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(parent_dir)
from mcp_utils import safe_tool


@safe_tool
def add(a: float, b: float) -> float:
    """返回两数之和"""
    return a + b

@safe_tool
def fibonacci(n: int) -> dict:
    """计算前 n 项斐波那契数列"""
    seq = [0, 1]
    for _ in range(2, n):
        seq.append(seq[-1] + seq[-2])
    return {"sequence": seq[:n]}

@safe_tool
def weather(location: str) -> dict:
    """
    简单天气工具示例，返回temperature + conditions
    """
    # 这是示例 stub，可以换成真实 API 调用
    return {"temperature": 62, "conditions": "Partly cloudy", "location": location}
